package com.hr.mq;


import com.hr.approval.entity.ApprovalData;
import com.hr.system.entity.SysDept;
import com.hr.system.entity.SysUser;
import io.swagger.annotations.Api;
import org.apache.rocketmq.spring.core.RocketMQTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.messaging.Message;
import org.springframework.messaging.support.MessageBuilder;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/api/mq1/")
@Api(tags = "初体验")
public class RocketmqController1 {
    //内部封装实现了RocketMQ的各种操作 发送
    @Autowired
    private RocketMQTemplate template;
    //发送消息
    @GetMapping("send1")
    public String send1(String msg){
//        Message<String> m= MessageBuilder.withPayload(msg).build();
        SysUser sysUser = new SysUser();
        sysUser.setId(12);
        sysUser.setState(1);
        sysUser.setType(2);
        template.convertAndSend("hr_work_approval",sysUser);
        return "OK";
    }
}